home *** CD-ROM | disk | FTP | other *** search
- ATARI MACHINE SPECIFIC LIBRARY
-
-
-
- NAME
- FastCounter - high speed incremental number display
-
- SYNOPSIS
- #include <FastCounter.h>
-
- class FastCounter
- class CounterFont
-
- DESCRIPTION
- Many real-time games and similar applications require a rapidly
- updated on-screen display for internal values such as score, or
- other often-changing value. This module provides very fast
- decimal counters, in user-defined fonts.
-
- CLASSES
- A FastCounter is a screen-displayable object that can be added
- to, subtracted from, or set to a specific value. It can be
- displayed with or without leading zeroes. It should not become
- negative.
-
- CLASS MEMBERS
- FastCounter::
-
- FastCounter(CounterFont*, int x, int y,
- unsigned v=0, short digits=6, short plane=0)
- Use given font, draw at screen pixel position (x,y), on the
- given bitplane, with initial counter value v, using the given
- number of digits, with zero suppression turned on by default.
-
- Digits will be rounded up to a multiple of 2.
- x will be rounded up to a multiple of 16.
-
- The bitplane draw on, and whas being drawn on determines the
- colour the counter will be drawn in. (See examples)
-
- void Draw()
- Draw on current page. (See DoubleBuffer)
-
- void Add(short)
- void operator ++ ()
- void operator -- ()
- void operator += (short x)
- void operator -= (short x)
- Increase/decrease.
-
- void Set(unsigned)
- Set to a value.
-
- FastCounter& operator = (unsigned x)
- Set to a value, return self.
-
- operator int()
- Convert to int.
-
- operator double()
- Convert to double.
-
- void MoveTo(short x,short y,short plane=0)
- Reposition on screen.
-
- void ZeroSuppression(bool on=TRUE)
- Enable/disable suppression of leading zeroes.
- Turned on by default.
-
- CounterFont::
-
- CounterFont(short Height)
- Create a font with digits on the given height.
-
- void GetImages(Screen&,short x,short y)
- Get image for the digits from the given (x,y) location of the given
- screen. (x,y) should be the top-left corner of the digit '0', and
- each digit should be 8-pixels wide, and side-by-side. If zero
- suppression is required, 8 pixels to the left of the '0' should
- specify the image for blank (usually just blank pixels).
- x must be multiple of 16.
-
- void Draw(short,long Offset)
- Draw a value at an offset into the current page.
- Usually only used by FastCounter.
- For 0<=x<=99, draw "00" to "99";
- For 99<x<110, draw " x-100";
- For x==110, draw " ".
-
- USAGE
- Create a screen with " 0123456789" depicted in all bitplanes
- (eg. use colour 15 in 16-colour modes)
-
- Each character 8 pixels wide, and all the same height.
-
- Create a CounterFont from this screen.
- Create FastCounters from this font.
-
- Different fonts may be used for different counters.
-
- Simply draw the counter at each iteration of the main animation
- loop, since it draws incrementally (ie. only draws if it's value
- changes, and then only those digits that changed).
-
- EXAMPLES
- If a colour 3 counter is required, the background would be either:
- colour 1, and draw the counter on bitplane 1 (1+2**1=3)
- colour 2, and draw the counter on bitplane 0 (2+2**0=3)
- colour 7, with the images of the digits draw in inverse,
- and draw the counter on bitplane 2 (7-2**2=3)
- colour 11, with the images of the digits draw in inverse,
- and draw the counter on bitplane 3 (11-2**3=3)
-
- Multi-coloured counters are possible - with a multicoloured
- background.
-
- SEE ALSO
- DoubleBuffer, Screen
-
- DIAGNOSTICS
- No range checking is performed.
-
- BUGS
- Only an even number of digits are allowed.
- Single-bitplane graphics can be confusing to the programmer.
-
- AUTHOR
- Warwick Allison, 1992.
- warwick@cs.uq.oz.au
-
- COPYING
- This functionality is part of the Atari Machine Specific Library,
- and is Copyright 1992 by Warwick W. Allison.
-
- The Atari Machine Specific Library is free and protected under the
- GNU Library General Public License.
-
- You are free to copy and modify these sources, provided you acknowledge
- the origin by retaining this notice, and adhere to the conditions
- described in the GNU LGPL.
-